//package com.csx.framework.springboot.sample.event;
//
//import org.springframework.cloud.context.environment.EnvironmentChangeEvent;
//import org.springframework.cloud.context.scope.refresh.RefreshScopeRefreshedEvent;
//import org.springframework.context.ApplicationEvent;
//import org.springframework.context.ApplicationListener;
//import org.springframework.stereotype.Component;
//
//import java.util.Set;
//
///**
// * <p> what does this class do ? </p>
// * <p> How does it work ?</p>
// * <p> Why does it do this ?</p>
// *
// * @author cuisongxu
// * @date 2024/12/30 周一 15:32
// */
//@Component
//public class SpringCloudInnerApplicationEvent implements ApplicationListener<ApplicationEvent> {
//
//    @Override
//    public void onApplicationEvent(ApplicationEvent event) {
//
//        /**
//         * 当 spring cloud 配置中心 关注的配置发生变更时,就会触发 ContextRefresher 刷新环境
//         * 会先后发布 EnvironmentChangeEvent 和 RefreshScopeRefreshedEvent
//         * 其中 EnvironmentChangeEvent 事件携带 变更配置的key 的列表
//         */
//        if(event instanceof EnvironmentChangeEvent e) {
//            Set<String> keys = e.getKeys();
//            System.out.println("环境发生改变,改变的 keys: " + keys);
//        }
//
//        if(event instanceof RefreshScopeRefreshedEvent) {
//            System.out.println("环境刷新");
//        }
//    }
//}
